﻿using FairyGUI;
using System;
using System.Linq;
using System.Text;

public abstract class BaseFlyPanel
{
	protected GComponent view;

	public bool IsOpen { get; private set; }

	public virtual void Init()
	{
		UIPackage.AddPackage("Main");
		this.view = CreateView();
	}

	public virtual void Show(params object[] para)
	{
		if (view != null)
		{
			GRoot.inst.AddChild(view);
			IsOpen = true;
		}
	}

	public virtual void Close()
	{
		if (view != null)
		{
			GRoot.inst.RemoveChild(view);
			IsOpen = false;
		}
	}

	public virtual void Dispose()
	{
		if (view != null)
		{
			if (IsOpen)
			{
				Close();
			}
			view.Dispose();
		}
	}

	protected abstract GComponent CreateView();
}
